home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Inspector / Sources / RegisteredObjects.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  3.9 KB  |  154 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        RegisteredObjects.h
  3.  
  4.     Contains:    Various classes for keeping track of instances of a certain class and making
  5.                 sure the test app keeps its windows updated.
  6.  
  7.     Copyright:    © 1991-1994 by Apple Computer, Inc., all rights reserved.
  8.  
  9. */
  10.  
  11. #ifndef __REGISTEREDOBJECTS__
  12. #define __REGISTEREDOBJECTS__
  13.  
  14. #ifndef __LIBRARYMANAGERCLASSES__
  15. #include <LibraryManagerClasses.h>
  16. #endif
  17.  
  18. class TInspector;
  19.  
  20. class TUpdateInspectorOp;
  21. class TRegisteredObjects;
  22. class TRegisteredObjectsWindow;
  23.  
  24. /**********************************************************************
  25. ** class TUpdateInspectorOp
  26. ***********************************************************************/
  27.  
  28. enum UpdateState {kScheduled, kExecuting, kFinished};
  29. enum UpdateCommand {kNone, kNew, kUpdate, kDelete, kDeleteAndDie};
  30.  
  31. #define kTUpdateInspectorOpID "slm:supp$upio,1.2"
  32.  
  33. class TUpdateInspectorOp : public TOperation 
  34. {
  35.     public:
  36.                                 _CDECL TUpdateInspectorOp();
  37.         virtual                    ~_CDECL TUpdateInspectorOp();
  38.         
  39.         virtual    void            _CDECL Process();
  40.         
  41.         // New Methods
  42.         
  43.                 UpdateState        GetState() const;
  44.                 void            SetState(UpdateState);
  45.                 UpdateCommand    GetCommand() const;
  46.                 void            SetCommand(UpdateCommand);
  47.                 TMacSemaphore*    GetSemaphore();
  48.  
  49.     private:
  50.         UpdateState            fState;
  51.         UpdateCommand        fCommand;
  52.         TMacSemaphore        fSemaphore;
  53. };
  54.  
  55. /*    -----------------------------------------------------------------
  56.     inline methods
  57.     ----------------------------------------------------------------- */
  58.  
  59.     inline UpdateState TUpdateInspectorOp::GetState() const
  60.     {
  61.         return fState;
  62.     }
  63.     
  64.     inline void TUpdateInspectorOp::SetState(UpdateState theState)
  65.     {
  66.         fState = theState;
  67.     }
  68.     
  69.     inline UpdateCommand TUpdateInspectorOp::GetCommand() const
  70.     {
  71.         return fCommand;
  72.     }
  73.     
  74.     inline void TUpdateInspectorOp::SetCommand(UpdateCommand theCommand)
  75.     {
  76.         fCommand = theCommand;
  77.     }
  78.     
  79.     inline TMacSemaphore* TUpdateInspectorOp::GetSemaphore()
  80.     {
  81.         return &fSemaphore;
  82.     }
  83.  
  84. /**********************************************************************
  85. ** class TRegisteredObjects
  86. ***********************************************************************/
  87.  
  88. #define kTRegisteredObjectsID "slm:supp$rego,1.2"
  89.  
  90. class TRegisteredObjects : public TDynamic
  91. {
  92. public:
  93.                                 _CDECL TRegisteredObjects(char *theName, TInspector** theInspector);
  94.     virtual                        ~_CDECL TRegisteredObjects();
  95.  
  96.     virtual    void                _CDECL Register(TDynamic *theObj);
  97.     virtual    void                _CDECL UnRegister(TDynamic *theObj);
  98.     virtual    void                _CDECL RegisterWithInspector();
  99.  
  100.             TInspector*            GetInspector() const;
  101.             unsigned long        GetCount() const;
  102.             TMacSemaphore*        GetSemaphore();
  103.             char*                GetClassName() const;
  104.             void                 SetRegisteredObjectsWindow(TRegisteredObjectsWindow*);
  105.             TRegisteredObjectsWindow* GetRegisteredObjectsWindow() const;
  106.             
  107.     virtual    TDynamic*            _CDECL operator[](size_t);
  108.  
  109. private:
  110.     TInspector**                fInspector;        /* ptr to the TClassCatalogs TInspector* field */
  111.     TLinkedList*                fObjects;        /* instances of this type */
  112.     char*                        fClassName;
  113.     TRegisteredObjectsWindow*    fRegisteredObjectsWindow;
  114.     TUpdateInspectorOp            fUpdateInspectorOp;    /* op for telling the Inspector about changes
  115.                                                         to the list */
  116.     TMacSemaphore                fSemaphore;
  117. };
  118.  
  119. /*    -----------------------------------------------------------------
  120.     Inline methods
  121.     ----------------------------------------------------------------- */
  122.     
  123.     inline TInspector* TRegisteredObjects::GetInspector() const
  124.     {
  125.         return *fInspector;
  126.     }
  127.     
  128.     inline unsigned long TRegisteredObjects::GetCount() const
  129.     {
  130.         return fObjects->Count();
  131.     }
  132.     
  133.     inline TMacSemaphore* TRegisteredObjects::GetSemaphore()
  134.     {
  135.         return &fSemaphore;
  136.     }
  137.     
  138.     inline char* TRegisteredObjects::GetClassName() const
  139.     {
  140.         return fClassName;
  141.     }
  142.     
  143.     inline void TRegisteredObjects::SetRegisteredObjectsWindow(TRegisteredObjectsWindow *theWindow) 
  144.     {
  145.         fRegisteredObjectsWindow = theWindow;
  146.     }
  147.     
  148.     inline TRegisteredObjectsWindow* TRegisteredObjects::GetRegisteredObjectsWindow()  const
  149.     {
  150.         return fRegisteredObjectsWindow;
  151.     }
  152.     
  153. #endif
  154.